#第一题
products = [["iphone",6888],["MacPro",14800],["小米6",2499],["Coffee",31],["Book",60],["Nike",699]]

print('----- 商品列表 ------')
for x,y in products:
    Goods = '{}\t\t{}'.format(x,y)
    print(Goods)

#第二题
shop_car = []
shop_cost = 0
GoodsID = 0

#打印商品列表
print('----- 商品列表 ------')
for x,y in products:
    GoodsID += 1
    Goods = '{}：{}  \t{}'.format(GoodsID,x,y)
    print(Goods)

#询问用户要买什么
while True:
    UserBuy = input('你想买什么，输入商品序号:')
    if UserBuy == 'q':
        break
    if 0< int(UserBuy) <= GoodsID:
        pass
    else:
        print('\n序号不对，重新输入\n:')
        continue
    shop_car.append(products[int(UserBuy)-1])
    shop_cost += int(products[int(UserBuy)-1][1])
print('\n您的购物车里有:\n')
for k,v in shop_car:
    print(k,v)
print('总共花费',shop_cost)
"""
需要显示的提醒用户来输入q
"""